//
//  SHAssetsUserListCell.m
//  youjian03
//
//  Created by Dadeso on 14-10-20.
//  Copyright (c) 2014年 com.shouhuobao. All rights reserved.
//

#import "SHAssetsUserListCell.h"

@implementation SHAssetsUserListCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        CGRect rect = CGRectMake(0, 0, 0, 0);
        
        UILabel * label = [[UILabel alloc] init];
        label.frame = rect;
        label.font = [UIFont systemFontOfSize:16.0f];
        label.textColor = [UIColor blackColor];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = NSTextAlignmentLeft;
        label.text = @"";
        self.assetsStyle = label;
        [self addSubview:self.assetsStyle];
        
        UILabel * label1 = [[UILabel alloc] init];
        label1.frame = rect;
        label1.font = [UIFont systemFontOfSize:16.0f];
        label1.textColor = [UIColor blackColor];
        label1.backgroundColor = [UIColor clearColor];
        label1.textAlignment = NSTextAlignmentLeft;
        label1.text = @"";
        self.assetsMoney = label1;
        [self addSubview:self.assetsMoney];
        
        UILabel * label2 = [[UILabel alloc] init];
        label2.frame = rect;
        label2.font = [UIFont systemFontOfSize:12.0f];
        label2.textColor = [UIColor grayColor];
        label2.backgroundColor = [UIColor clearColor];
        label2.textAlignment = NSTextAlignmentLeft;
        label2.text = @"";
        self.assetsTimeOutDate = label2;
        [self addSubview:self.assetsTimeOutDate];
//        [self initLabel:self.assetsStyle Frame:rect Font:12.0f TextColor:[UIColor blackColor] Text:@""] ;
//        [self initLabel:self.assetsMoney Frame:rect Font:12.0f TextColor:[UIColor blackColor] Text:@""] ;
//        [self initLabel:self.assetsTimeOutDate Frame:rect Font:8.0f TextColor:[UIColor grayColor] Text:@""] ;
        
    }
    return self;
}


-(void)assetsUserListCell:(NSString *)strCell IndexPaht:(NSIndexPath *)cellIndexPath{
    /*
     
     红包数据判读  if(amount>0) self.assetsStyle.textColor = [UIColor redColor];
     
     */
    self.assetsStyle.text = @"使用红包";
    [self.assetsStyle setFrame:CGRectMake(10, 15, [self ToCalculateTheCellWidth:self.assetsStyle.font andLabelText:self.assetsStyle.text] , 16)];
    self.assetsMoney.text = [NSString stringWithFormat:@"+%d元",10];
    self.assetsMoney.textColor = [UIColor redColor];
    [self.assetsMoney setFrame:CGRectMake(10 + self.assetsStyle.frame.origin.x + self.assetsStyle.frame.size.width, 15, [self ToCalculateTheCellWidth:self.assetsMoney.font andLabelText:self.assetsMoney.text] , 16)];
    self.assetsTimeOutDate.text = @"2014.10.21";
    [self.assetsTimeOutDate setFrame:CGRectMake(320 -[self ToCalculateTheCellWidth:self.assetsTimeOutDate.font andLabelText:self.assetsTimeOutDate.text] - 10, 19, [self ToCalculateTheCellWidth:self.assetsTimeOutDate.font andLabelText:self.assetsTimeOutDate.text] , 12)];
    
    UIImageView * lineImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.origin.x, self.frame.size.height - 0.5, self.frame.size.width, 0.5)];
    lineImageView.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:lineImageView];
}

//-(void)initLabel:(UILabel *)currentLabel Frame:(CGRect)labelFrame Font:(CGFloat)labelFont TextColor:(UIColor *)textColor Text:(NSString *)labelText{
//    UILabel * label = [[UILabel alloc] init];
//    label.frame = labelFrame;
//    label.font = [UIFont systemFontOfSize:labelFont];
//    label.textColor = textColor;
//    label.backgroundColor = [UIColor blackColor];
//    label.textAlignment = NSTextAlignmentLeft;
//    label.text = labelText;
//    currentLabel = label;
//    [self addSubview:currentLabel];
//}

-(CGFloat)ToCalculateTheCellWidth:(UIFont *)labelFont andLabelText:(NSString *)labelText{
    
    NSDictionary *attrs = @{NSFontAttributeName : labelFont};
    CGFloat titleW = [labelText boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size.width;
    return titleW;
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
